
					tp->tv_sec = STIMER;		// Set current time
					tp->tv_usec = UTIMER;		// Set timeout time
					
					//message saying file is being sent
					cout << "Sending file to " << clientHostName << ", waiting..." << endl;

					//print info to log
					if(TRACE)
						fprintf(filelog, "Sender: sending file %s to %s\n", three_way_hs.file_name, clientHostName);

					//open file to be sent as fileout 
					ifstream fileout;

					//open for input in binary mode
					fileout.open(three_way_hs.file_name, ios_base::in | ios_base::binary );

					//check if the requested file exists
					if (!fileout.is_open()) //file does not exit
					{
						//send packet to client indicating the file doesn't exist on the server
						message_frame.header = '9'; //char 9 indicates an error
					
						//send error message to client
						//send(s, (char *)&message_frame, sizeof(message_frame), 0);	//For TCP
						sendto(s, (const char*)&message_frame, sizeof(message_frame), 0, (struct sockaddr*)&sa, sizeof(sa));

						//if file does not exist: error message
						cout <<"ERROR: File Does Not Exist!" << endl;
						cout << "File " << three_way_hs.file_name << " cannot be sent to client " << clientHostName << "!" << endl;
					}
					else //file exists
					{
						//get the file size
						fileout.seekg (0, ios::end);
						int filesize = fileout.tellg();
						fileout.seekg (0, ios::beg);

						//keep track of the bits already read
						bitsread = 0;
						//keep track of the bits left to read
						bitsleft = filesize;

						//bool to flag when the file as been completely received
						bool lastpacket = false;

						//keep sending packets containing the file data until there are no more bits to read
						while(lastpacket == false){

							//if data is at the begining or middle of the file
							if(bitsleft > MAX_SIZE){

								//char 1 means this packet is in the middle
								message_frame.header = '1';

								//read data into the packet until the alloted size is reached
								fileout.read(message_frame.data, MAX_SIZE);

								//change bits read and bits left accordingly
								bitsleft = bitsleft - MAX_SIZE;
								bitsread = bitsread + MAX_SIZE;

								//send packet to server
								//send(s, (char *)&message_frame, sizeof(message_frame), 0);	//For TCP
								sendto(s, (const char*)&message_frame, sizeof(message_frame), 0, (struct sockaddr*)&sa, sizeof(sa));

								//print info to log
								if(TRACE)
									fprintf(filelog, "Sender: packet sent to %s: %dbytes\n", clientHostName, MAX_SIZE);

								//flag that this is not the last packet
								lastpacket = false;
							}
							else //if data is at the end of the file
								if(bitsleft <= MAX_SIZE){

									//char 2 means this packet is the last
									message_frame.header = (unsigned char)bitsleft;

									//since we will not fill the entire message_frame.data, clear it
									memset(message_frame.data, 0, sizeof(message_frame.data));

									//read data into the packet until the alloted size is reached
									fileout.read(message_frame.data, bitsleft);

									//change bits read and bits left accordingly
									bitsleft = bitsleft - bitsleft;
									bitsread = bitsread + bitsleft;

									//send packet to server
									//send(s, (char *)&message_frame, sizeof(message_frame), 0);	//For TCP
									sendto(s, (const char*)&message_frame, sizeof(message_frame), 0, (struct sockaddr*)&sa, sizeof(sa));

									//print info to log
									if(TRACE)
										fprintf(filelog, "Sender: last packet sent to %s: %dbytes\n", clientHostName, message_frame.header);

									//flag that this is the last packet
									lastpacket = true;
								}
						}
					}

					//get file size
					fileout.seekg(0, ios::end);
					int filesizeout = fileout.tellg();

					//close the file
					fileout.close();

					//print info to log
					if(TRACE)
						fprintf(filelog, "Sender: file %s completely sent to %s: %dbytes\n", three_way_hs.file_name, clientHostName, filesizeout);

					//send message as long as there is no error
					if(message_frame.header != '9')
						//message saying file has been sent
						cout << "File " << three_way_hs.file_name << " sent to client " << clientHostName << "!" << endl;